define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    if(Config.dns_id == '' || Config.dns_id == null){
        Config.dns_id = 0;
    }
    if(Config.type_id == '' || Config.type_id == null){
        Config.type_id = 0;
    }
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'dnsanalysis/index/?dns_id=' + Config.dns_id + '&type_id=' + Config.type_id,
                    add_url: 'dnsanalysis/add',
                    edit_url: 'dnsanalysis/edit',
                    multi_url: 'dnsanalysis/multi',
                    import_url: 'dnsanalysis/import',
                    table: 'dns_analysis',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'type_id_name', title: __('Type_id')},
                        {field: 'dns_id_name', title: __('Dns_id')},
                        // {field: 'new_domain_name', title: __('New_domain_name'), operate: 'LIKE'},
                        {field: 'operating_instructions', title: __('Operating_instructions'), operate: 'LIKE'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'type', title: __('类型'), searchList: {"1":__('绑定域名'),"2":__('删除域名')}, formatter: Table.api.formatter.status,custom: {1:'success', 2:'danger'}},
                        {field: 'status', title: __('Status'), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});